class DefaultSettings < ActiveRecord::Migration
  def self.up
    create_table "categories", :force => true do |t|
      t.column "name",        :string,   :default => "", :null => false
      t.column "image",       :string,   :default => "", :null => false
      t.column "creation",    :datetime,                 :null => false
      t.column "description", :text
    end

    create_table "comments", :force => true do |t|
      t.column "media_id", :integer,  :default => 0,  :null => false
      t.column "name",     :string,   :default => "", :null => false
      t.column "email",    :string,   :default => "", :null => false
      t.column "creation", :datetime,                 :null => false
      t.column "comment",  :text
    end

    create_table "extplugins", :force => true do |t|
      t.column "name",      :string,  :default => "", :null => false
      t.column "activated", :integer, :default => 0,  :null => false
      t.column "order",     :integer, :default => 0,  :null => false
      t.column "config",    :text
    end

    create_table "links", :force => true do |t|
      t.column "name",        :string, :default => "", :null => false
      t.column "description", :string, :default => "", :null => false
      t.column "url",         :string, :default => "", :null => false
    end

    create_table "medias", :force => true do |t|
      t.column "title",        :string,                 :default => "", :null => false
      t.column "type_id",      :integer,                :default => 0,  :null => false
      t.column "path",         :string,                 :default => "", :null => false
      t.column "text",         :text
      t.column "creation",     :datetime,                               :null => false
      t.column "modification", :datetime,                               :null => false
      t.column "user_id",      :integer,                :default => 0,  :null => false
      t.column "visibility",   :string,   :limit => 50, :default => "", :null => false
      t.column "tags",         :string,                 :default => "", :null => false
      t.column "permalink",    :string,                 :default => "", :null => false
      t.column "published",    :integer,                :default => 0,  :null => false
      t.column "category_id",  :integer,                :default => 0,  :null => false
    end
    
    create_table "users", :force => true do |t|
      t.column "login", :string, :limit => 80
      t.column "password", :string, :limit => 40
      t.column "email", :string, :default => "", :null => false
    end

    create_table "settings", :force => true do |t|
      t.column "title",               :string,                :default => "",        :null => false
      t.column "subtitle",            :string,                :default => "",        :null => false
      t.column "admin_email",         :string,                :default => "",        :null => false
      t.column "url",                 :string,                :default => "",        :null => false
      t.column "theme",               :string,  :limit => 50, :default => "default", :null => false
      t.column "stats",               :integer,               :default => 0,         :null => false
      t.column "mail_host",           :string,                :default => "",        :null => false
      t.column "mail_user",           :string,                :default => "",        :null => false
      t.column "mail_password",       :string,                :default => "",        :null => false
      t.column "mail_domain",         :string,                :default => "",        :null => false
      t.column "mail_authentication", :string,  :limit => 10, :default => "none",    :null => false
      t.column "mail_port",           :integer,               :default => 25,        :null => false
      t.column "mail_notification",   :integer,               :default => 0,         :null => false
    end

    create_table "sitealizer", :force => true do |t|
      t.column "path",       :string
      t.column "ip",         :string
      t.column "referer",    :string
      t.column "language",   :string
      t.column "user_agent", :string
      t.column "created_at", :datetime
      t.column "created_on", :date
    end

    create_table "types", :force => true do |t|
      t.column "name", :string, :limit => 50, :default => "", :null => false
    end

    create_table "visits", :force => true do |t|
      t.column "ip",      :string,   :limit => 12, :default => "", :null => false
      t.column "date",    :datetime,                               :null => false
      t.column "path",    :text
      t.column "browser", :string,                 :default => "", :null => false
      t.column "host",    :text
    end
    
    Setting.create :title=>"Title",:subtitle=>"subtitle"
	  Category.create :name=>"general",:image=>"asterisk_yellow.png",:creation=>Time.now
	  Link.create :name=>"www.rubyonrails.org",:url=>"http://www.rubyonrails.org/",:description=>"Official RoR website"
	  Type.create :name=>"article"
	  Type.create :name=>"page"
	  Extplugin.create :name=>'pagelist',:activated=>1,:order=>7,:config=>'--- !map:HashWithIndifferentAccess title: Pages'
	  Extplugin.create :name=>'search',:activated=>1,:order=>6,:config=>'--- !map:HashWithIndifferentAccess title: Search'
	  Extplugin.create :name=>'linklist',:activated=>1,:order=>5,:config=>'--- !map:HashWithIndifferentAccess title: Link list'
	  Extplugin.create :name=>'categorylist',:activated=>1,:order=>0,:config=>'--- !map:HashWithIndifferentAccess title: Categories'
	  Extplugin.create :name=>'archives',:activated=>1,:order=>1,:config=>'--- !map:HashWithIndifferentAccess title: Archives'
	  Extplugin.create :name=>'quicklinks',:activated=>1,:order=>2,:config=>'--- !map:HashWithIndifferentAccess title: Quick links'
	  Extplugin.create :name=>'themeswitch',:activated=>1,:order=>3,:config=>'--- !map:HashWithIndifferentAccess title: Themes'
	  Extplugin.create :name=>'langswitch',:activated=>1,:order=>4,:config=>'--- !map:HashWithIndifferentAccess title: Langue'
  end

  def self.down
    drop_table "categories"
    drop_table "comments"
    drop_table "extplugins"
    drop_table "links"
    drop_table "medias"
    drop_table "users"
    drop_table "settings"
    drop_table "sitealizer"
    drop_table "types"
    drop_table "visits"
  end
end